import http from '@/utils/http.js'
import {useKuYiStore} from '@/stores'
// const useStore = useKuYiStore()

// 登录
export const getKuyiToken = ({username,password})=> http.post('/api/login.php',{username,password})

//楼宇管理
export const postLouYu = (data)=>http.post('/api/building.php',data,{
    headers:{
        'Content-Type': 'application/json'
    }
})
// 单元管理---------------------------------------------------------------------------

// 单元管理
export const getDanYuan = (data)=>http.post('/api/unit.php',data,{
    headers:{
        'Content-Type': 'application/json'
    }
})

// 添加单元
export const addDanYuan = ({action,building,unit_number})=>http.post('/api/unit.php',{action,building,unit_number},{
    headers:{
        'Content-Type': 'application/json'
    }
})

// 删除单元
export const delDanYuan = ({action,id})=>http.post('/api/unit.php',{action,id},{
    headers:{
        'Content-Type': 'application/json'
    }
})

// 单元筛选 filter
export const filterDanyuan = (value)=>http.post('/api/unit.php',{action:'filter',building:value},{
    headers:{
        'Content-Type':'application/json'
    }
})

// 房屋管理---------------------------------------------------------------------------

// 查询单元和房屋
export const listHouse = (data) => http.post('/api/house.php', {action: 'list',data,},{
    headers:{
        'Content-Type': 'application/json'
    }
})

// 增加房屋
export const addHouses = (data) =>http.post('/api/house.php',{action:'add',...data},{
    headers:{
        'Content-Type' : 'application/json'
    }
});

// 删除单元和房屋
export const deleteHouse = (id) => http.post('/api/house.php', {action:'del', id},{
    headers:{
        'Content-Type':'application/json'
    }
});

// 更新单元和房屋
export const updateHouse = (data) =>http.post('/api/house.php', {action: 'update',...data},{
    headers:{
        'Content-Type':'application/json'
    }
});

// 查询单条记录
export const findHouse = (id) =>http.post('/api/house.php', {action: 'find',id},{
    headers:{
        'Content-Type':'application/json'
    }
});

// 筛选房屋
export const filterHouses = (filterParams) =>http.post('/api/house.php', {action: 'filter',filterParams},{
    headers:{
        'Content-Type':'application/json'
    }
});


// 宾馆管理
export const hotelManagement = (action) =>http.post('/api/store/hotel.php',{...action},{
    headers:{
        'Content-Type':'application/json'
    }
})

// 添加宾馆
export const setHotelInfo = (data)=>http.post('/api/store/hotel.php',{action:'add',...data},{
    headers:{
        'Content-Type':'application/json'
    }
})

// 更新宾馆
export const updateHotelInfo=(data)=>http.post('/api/store/hotel.php',{action:'update',...data},{
    headers:{
        'Content-Type':'application/json'
    }
})
// 删除宾馆
export const delHotelInfo=(id)=>http.post('/api/store/hotel.php',{action:'del',id},{
    headers:{
        'Content-Type':'application/json'
    }
})

// 每日状态页
export const everydayStore=(date)=>http.post('/api/store/hotstatus.php',{date},{
    headers:{
        'Content-Type':'application/json'
    }
})

// 用户管理
export const getUser = (data) =>http.post('/api/user.php',{action:'list',...data},{
    headers:{
        'Content-Type':'application/json'
    }
})

// 增加用户
export const addUser = (data) =>http.post('/api/user.php',{action:'add',...data},{
    headers:{
        'Content-Type':'application/json'
    }
})

// 修改用户
export const updateUser = (data) =>http.post('/api/user.php',{action:'update',...data},{
    headers:{
        'Content-Type':'application/json'
    }
})

// 删除用户
export const delUser = (id) =>http.post('/api/user.php',{action:'del',id},{
    headers:{
        'Content-Type':'application/json'
    }
})